package com.ruoyi.index.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.index.dto.UserDto;
import com.ruoyi.index.exception.MyException;
import com.ruoyi.index.service.UserService;
import com.ruoyi.index.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author dell
* @description 针对表【sys_user(用户信息表)】的数据库操作Service实现
* @createDate 2025-03-17 21:46:42
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserDto>
    implements UserService{
    @Autowired
    private UserMapper userMapper;

    @Override
    public void addUser(UserDto userDto){
        userMapper.insert(userDto);
    }

    @Override
    public UserDto selectUserName(String userName) {
        QueryWrapper<UserDto> qr = new QueryWrapper<>();
        qr.eq("user_name",userName);
        return userMapper.selectOne(qr);
    }

    @Override
    public UserDto loginUser(UserDto userDto) {
        QueryWrapper<UserDto> qr = new QueryWrapper<>();
        qr.eq("user_name",userDto.getUserName());
        return userMapper.selectOne(qr);
    }
}




